//
//  AccountService.m
//  ZYWL
//
//  Created by lcy on 16/1/6.
//  Copyright © 2016年 ruiyun. All rights reserved.
//

#import "AccountService.h"
#import "Model.h"

@implementation AccountService

#pragma mark - 登录
- (void)LoginPhone:(NSString *)phone smsCode:(NSString *)smsCode {
    //    loginType 0密码登录 1短信登录
    _hostUrl = [NSString stringWithFormat:@"%@login/login",HOST];
//    self.modelclass = [UserInfo class];
    self.keyStr = @"data";
    _paramDict[@"mobile"] = phone;
    _paramDict[@"verifyCode"] = smsCode;
    _paramDict[@"deviceType"] = @"1";
    _paramDict[@"deviceNo"]  = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
    _paramDict[@"regChannel"] = @"iOSTest";
    _paramDict[@"sign"] = @"";
    //启动业务
//    _reponseType = TYPE_OTHER;
    self.decodeData = ^id(id data) {
        return [data objectForKey:@"data"];
    };
    [self startPostRequest];
}

//发送验证码
- (void)sendCode:(NSString *)phone {
    _hostUrl = [NSString stringWithFormat:@"%@login/sendCode",HOST];

    _paramDict[@"mobile"] = phone;
    _paramDict[@"sign"] = @"";
    //启动业务
    self.decodeData = ^id(id data) {
        return data;
    };
    //    _reponseType = TYPE_OTHER;
    [self startPostRequest];
}

//查询用户信息
- (void)findUserInfo {
    _hostUrl = [NSString stringWithFormat:@"%@users/findInfo",HOST];
    self.modelclass = [UserInfo class];
    self.keyStr = @"data";
    _paramDict[@"usersId"] = [NSString stringWithFormat:@"%@",KUSER.usersId];
    _paramDict[@"token"] = [UserDefaultStandard objectForKey:@"token"];
    _paramDict[@"sign"] = @"";
    //启动业务

    [self startPostRequest];
}

//查询用户信息
- (void)findOtherUserInfo:(NSString *)userId {
    _hostUrl = [NSString stringWithFormat:@"%@users/findInfo",HOST];
    self.modelclass = [UserInfo class];
    self.keyStr = @"data";
    _paramDict[@"usersId"] = userId;
    _paramDict[@"loginUsersId"] = [NSString stringWithFormat:@"%@",KUSER.usersId];

    _paramDict[@"token"] = [UserDefaultStandard objectForKey:@"token"];
    
    _paramDict[@"sign"] = @"";
    
    [self startPostRequest];
}

//修改用户信息
- (void)updUsersInfo:(NSString *)portraitId nickName:(NSString *)nickName sex:(NSString *)sex  portraitMap:(UIImage *)portraitMap{
    _hostUrl = [NSString stringWithFormat:@"%@users/updUsersInfo",HOST];
    _paramDict[@"portraitId"] = portraitId;
    _paramDict[@"nickName"] = [self replacernk:nickName];
    _paramDict[@"token"] = [UserDefaultStandard objectForKey:@"token"];
//    0女1男
    _paramDict[@"sex"] = sex;
    _paramDict[@"usersId"] = [NSString stringWithFormat:@"%@",KUSER.usersId];
    //头像
    UIImage *originImage = portraitMap;
    NSData *data =   [UIImage resetSizeOfImageData:originImage maxSize:50];
    NSString *encodedImageStr = [data base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];
    encodedImageStr = [encodedImageStr stringByReplacingOccurrencesOfString:@"\r" withString:@""];
    encodedImageStr = [encodedImageStr stringByReplacingOccurrencesOfString:@"\n" withString:@""];
    encodedImageStr = [encodedImageStr stringByReplacingOccurrencesOfString:@" " withString:@""];
    _paramDict[@"portraitMap"] = encodedImageStr;
    _paramDict[@"sign"] = @"";
    //启动业务
    self.decodeData = ^id(id data) {
        return data;
    };
    //    _reponseType = TYPE_OTHER;
    [self startPostRequest];
}

//修改用户头像
- (void)updUsersInfo:(NSString *)portraitId portraitMap:(UIImage *)portraitMap{
    _hostUrl = [NSString stringWithFormat:@"%@users/updUsersInfo",HOST];
    _paramDict[@"portraitId"] = portraitId;
    _paramDict[@"token"] = [UserDefaultStandard objectForKey:@"token"];
    _paramDict[@"usersId"] = [NSString stringWithFormat:@"%@",KUSER.usersId];
    //头像
    UIImage *originImage = portraitMap;
    NSData *data =   [UIImage resetSizeOfImageData:originImage maxSize:50];
    NSString *encodedImageStr = [data base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];
    encodedImageStr = [encodedImageStr stringByReplacingOccurrencesOfString:@"\r" withString:@""];
    encodedImageStr = [encodedImageStr stringByReplacingOccurrencesOfString:@"\n" withString:@""];
    encodedImageStr = [encodedImageStr stringByReplacingOccurrencesOfString:@" " withString:@""];
    _paramDict[@"portraitMap"] = encodedImageStr;
    _paramDict[@"sign"] = @"";
    //启动业务
    self.decodeData = ^id(id data) {
        return data;
    };
    //    _reponseType = TYPE_OTHER;
    [self startPostRequest];
}
//查询头像
- (void)findUsersPortraitSex:(NSString *)sex{
    _hostUrl = [NSString stringWithFormat:@"%@usersPortrait/find",HOST];
    // 0女1男
    _paramDict[@"sex"] = sex;
    _paramDict[@"usersId"] = [NSString stringWithFormat:@"%@",KUSER.usersId];
    _paramDict[@"sign"] = @"";
    //启动业务
    self.modelclass = [PortraitModel class];
    self.keyStr = @"data";
    _reponseType = TYPE_ARRAY;
    [self startPostRequest];
}

//上传图片
-(void)uploadImage:(NSString *)oid image:(UIImage *)image{
    NSString *str = HOST;
    _hostUrl = [str stringByAppendingString:@"app/user/upload"];
//    _paramDict[@"oid"] = oid;
    self.decodeData = ^id(id data) {
        return data;
    };
    self.icon = image;
    [self startUpload:@"portrait"];
}



//用户签到
- (void)userSign{
    _hostUrl = [NSString stringWithFormat:@"%@users/sign",HOST];
    _paramDict[@"usersId"] = [NSString stringWithFormat:@"%@",KUSER.usersId];
    _paramDict[@"token"] = [UserDefaultStandard objectForKey:@"token"];
    _paramDict[@"sign"] = @"";
    //启动业务
    self.decodeData = ^id(id data) {
        return data;
    };
    //    _reponseType = TYPE_OTHER;
    [self startPostRequest];
}
//步数兑换车票
- (void)userStepToTicket{
    _hostUrl = [NSString stringWithFormat:@"%@users/stepToTicket",HOST];
    _paramDict[@"usersId"] = [NSString stringWithFormat:@"%@",KUSER.usersId];
    _paramDict[@"token"] = [UserDefaultStandard objectForKey:@"token"];
    _paramDict[@"sign"] = @"";
    //启动业务
    self.decodeData = ^id(id data) {
        return data;
    };
    //    _reponseType = TYPE_OTHER;
    [self startPostRequest];
}
//获取步数
- (void)findStep:(NSString *)step{
    _hostUrl = [NSString stringWithFormat:@"%@users/findStep",HOST];
    _paramDict[@"usersId"] = [NSString stringWithFormat:@"%@",KUSER.usersId];
    _paramDict[@"stepNum"] = step;

    _paramDict[@"sign"] = @"";
    //启动业务
    self.decodeData = ^id(id data) {
        return data;
    };
    //    _reponseType = TYPE_OTHER;
    [self startPostRequest];
}
//新增故事
- (void)addStory:(NSString *)storyName angelId:(NSString *)angelId questionList:(NSMutableArray *)questionList lat:(NSString *)lat lng:(NSString *)lng{
    _hostUrl = [NSString stringWithFormat:@"%@story/addStory",HOST];
    _paramDict[@"usersId"] = [NSString stringWithFormat:@"%@",KUSER.usersId];
    //编辑的时候传
    _paramDict[@"storyName"] = @"";
//    storyName;
    _paramDict[@"angelId"] = @"-1";
//    KUSER.portraitIm;
    _paramDict[@"isDefault"] = @"1";
    _paramDict[@"sucText"] = @"";
    _paramDict[@"failText"] = @"";
    _paramDict[@"createType"] = @"1";
    _paramDict[@"questionList"] = questionList;
    
    _paramDict[@"lng"] = lng;
    _paramDict[@"lat"] = lat;
    
    _paramDict[@"token"] = [UserDefaultStandard objectForKey:@"token"];

     _paramDict[@"sign"] = @"";
    //启动业务
    self.decodeData = ^id(id data) {
        return data;
    };
    //    _reponseType = TYPE_OTHER;
    [self startPostRequest];
}
//编辑故事
- (void)updateStory:(NSString *)storyName storyId:(NSString *)storyId angelId:(NSString *)angelId questionList:(NSMutableArray *)questionList lat:(NSString *)lat lng:(NSString *)lng{
    _hostUrl = [NSString stringWithFormat:@"%@story/updateStory",HOST];
    _paramDict[@"usersId"] = [NSString stringWithFormat:@"%@",KUSER.usersId];
    //编辑的时候传
    _paramDict[@"storyId"] = storyId;
     _paramDict[@"storyName"] = @"";
//    storyName;
//    _paramDict[@"angelId"] = angelId;
    _paramDict[@"angelId"] = @"-1";
    _paramDict[@"isDefault"] = @"1";
    _paramDict[@"sucText"] = @"";
    _paramDict[@"failText"] = @"";
    _paramDict[@"createType"] = @"1";
    _paramDict[@"questionList"] = questionList;
    _paramDict[@"lng"] = lng;
    _paramDict[@"lat"] = lat;
    
    _paramDict[@"token"] = [UserDefaultStandard objectForKey:@"token"];
    _paramDict[@"sign"] = @"";
    //启动业务
    self.decodeData = ^id(id data) {
        return data;
    };
    //    _reponseType = TYPE_OTHER;
    [self startPostRequest];
}

//删除故事
- (void)removeStoryByStoryId:(NSString *)storyId{
    _hostUrl = [NSString stringWithFormat:@"%@story/removeStory",HOST];
    _paramDict[@"usersId"] = [NSString stringWithFormat:@"%@",KUSER.usersId];
    _paramDict[@"storyId"] = storyId;
    _paramDict[@"token"] = [UserDefaultStandard objectForKey:@"token"];
    _paramDict[@"sign"] = @"";
    //启动业务
    self.keyStr = @"data";
    self.decodeData = ^id(id data) {
        return data;
    };
    [self startPostRequest];
}
//根据用户查询故事
- (void)findStoryByUsersId:(NSString *)userId{
    _hostUrl = [NSString stringWithFormat:@"%@story/findByUsersId",HOST];
    _paramDict[@"usersId"] = userId;
    _paramDict[@"token"] = [UserDefaultStandard objectForKey:@"token"];
    _paramDict[@"sign"] = @"";
    //启动业务
    self.keyStr = @"data";
    self.decodeData = ^id(id data) {
        return [data objectForKey:@"data"];
    };
    [self startPostRequest];
}
//根据故事id查询故事详情
- (void)findStoryByStoryId:(NSString *)storyId{
    _hostUrl = [NSString stringWithFormat:@"%@story/findByStoryId",HOST];
    _paramDict[@"usersId"] = [NSString stringWithFormat:@"%@",KUSER.usersId];
    _paramDict[@"storyId"] = storyId;
    _paramDict[@"token"] = [UserDefaultStandard objectForKey:@"token"];
    _paramDict[@"ticket"] = @"0";
    _paramDict[@"sign"] = @"";
    //启动业务
    self.keyStr = @"data";
    self.decodeData = ^id(id data) {
        return [data objectForKey:@"data"];
    };
    [self startPostRequest];
}
//根据故事id查询故事详情kouchepiap
- (void)findStoryByTicketStoryId:(NSString *)storyId{
    _hostUrl = [NSString stringWithFormat:@"%@story/findByStoryId",HOST];
    _paramDict[@"usersId"] = [NSString stringWithFormat:@"%@",KUSER.usersId];
    _paramDict[@"storyId"] = storyId;
    _paramDict[@"token"] = [UserDefaultStandard objectForKey:@"token"];
    _paramDict[@"ticket"] = @"1";
    _paramDict[@"sign"] = @"";
    //启动业务
    self.keyStr = @"data";
    self.decodeData = ^id(id data) {
        return [data objectForKey:@"data"];
    };
    [self startPostRequest];
}
//故事点赞
- (void)addPrase:(NSString *)storyId storyVersion:(NSString *)storyVersion{
    _hostUrl = [NSString stringWithFormat:@"%@story/addPrase",HOST];
    _paramDict[@"usersId"] = [NSString stringWithFormat:@"%@",KUSER.usersId];
    _paramDict[@"storyId"] = storyId;
    _paramDict[@"storyVersion"] = storyVersion;
    _paramDict[@"token"] = [UserDefaultStandard objectForKey:@"token"];
    _paramDict[@"sign"] = @"";
    //启动业务
    self.keyStr = @"data";
    self.decodeData = ^id(id data) {
        return data;
    };
    [self startPostRequest];
}

//根据关注查询故事
- (void)storyFindByFriends:(NSString *)pageNo{
    _hostUrl = [NSString stringWithFormat:@"%@story/findByFriends",HOST];
    _paramDict[@"type"] = @"0";
    _paramDict[@"usersId"] = [NSString stringWithFormat:@"%@",KUSER.usersId];
    _paramDict[@"sign"] = @"";
    _paramDict[@"pageNo"] = pageNo;
    _paramDict[@"pageSize"] = @"10";
    _paramDict[@"token"] = [UserDefaultStandard objectForKey:@"token"];
    //启动业务
    self.modelclass = [MTPlayGroundModel class];
    self.keyStr = @"data";
    _reponseType = TYPE_ARRAY;
    [self startPostRequest];
}
//根据推荐查询故事
- (void)storyFindByRec:(NSString *)pageNo{
    _hostUrl = [NSString stringWithFormat:@"%@story/findByRec",HOST];
    _paramDict[@"type"] = @"0";
    _paramDict[@"usersId"] = [NSString stringWithFormat:@"%@",KUSER.usersId];
    _paramDict[@"pageNo"] = pageNo;
    _paramDict[@"pageSize"] = @"10";    
    _paramDict[@"sign"] = @"";
    _paramDict[@"token"] = [UserDefaultStandard objectForKey:@"token"];

    //启动业务
    self.modelclass = [MTPlayGroundModel class];
    self.keyStr = @"data";
    _reponseType = TYPE_ARRAY;
   
    [self startPostRequest];
}

//修改用户位置
- (void)updUsersInfolng:(NSString *)lng lat:(NSString *)lat{
    _hostUrl = [NSString stringWithFormat:@"%@users/updUsersInfo",HOST];
    _paramDict[@"lng"] = lng;
    _paramDict[@"lat"] = lat;
    _paramDict[@"token"] = [UserDefaultStandard objectForKey:@"token"];
    _paramDict[@"usersId"] = [NSString stringWithFormat:@"%@",KUSER.usersId];
    _paramDict[@"sign"] = @"";
    //启动业务
    self.decodeData = ^id(id data) {
        return data;
    };
    //    _reponseType = TYPE_OTHER;
    [self startPostRequest];
}
//首页查询用户
- (void)findIndexStorylat:(NSString *)lat lng:(NSString *)lng{
//    _hostUrl = [NSString stringWithFormat:@"%@story/findIndexStory",HOST];
    _hostUrl = [NSString stringWithFormat:@"%@story/findIndexStory1_6",HOST];
    _paramDict[@"usersId"] = [NSString stringWithFormat:@"%@",KUSER.usersId];
    
    _paramDict[@"lng"] = lng;
    _paramDict[@"lat"] = lat;
    
    NSString *sex2 = @"";
    NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults];
    NSString *sex = [userDefault objectForKey:@"sex"];
    if ([sex isEqualToString:@"1"]) {
        sex2 = @"1";
    }else if ([sex isEqualToString:@"2"]) {
        sex2 = @"0";
    }else if ([sex isEqualToString:@"3"]) {
        sex2 = @"";
    }    
    _paramDict[@"sex"] = sex2;

    _paramDict[@"sign"] = @"";
    _paramDict[@"token"] = [UserDefaultStandard objectForKey:@"token"];
    //启动业务
//    self.modelclass = [FindModel class];
//    self.keyStr = @"data";
//    _reponseType = TYPE_ARRAY;
    self.keyStr = @"data";
    self.decodeData = ^id(id data) {
        return [data objectForKey:@"data"];
    };
    [self startPostRequest];
}

//查询关注
- (void)findFriends:(NSString *)pageNo{
    _hostUrl = [NSString stringWithFormat:@"%@friends/find",HOST];
    _paramDict[@"usersId"] = [NSString stringWithFormat:@"%@",KUSER.usersId];
    _paramDict[@"type"] = @"0";
//    _paramDict[@"pageNo"] = pageNo;
//    _paramDict[@"pageSize"] = @"10";
    _paramDict[@"sign"] = @"";
    _paramDict[@"token"] = [UserDefaultStandard objectForKey:@"token"];
    //启动业务
    self.modelclass = [FoucsModel class];
    self.keyStr = @"data";
    _reponseType = TYPE_ARRAY;
   
    [self startPostRequest];
}
//查询粉丝
- (void)findFriendsFans:(NSString *)pageNo{
    _hostUrl = [NSString stringWithFormat:@"%@friends/find",HOST];
    _paramDict[@"usersId"] = [NSString stringWithFormat:@"%@",KUSER.usersId];
    _paramDict[@"type"] = @"1";
    //    _paramDict[@"pageNo"] = pageNo;
    //    _paramDict[@"pageSize"] = @"10";
    _paramDict[@"token"] = [UserDefaultStandard objectForKey:@"token"];
    _paramDict[@"sign"] = @"";
    
    //启动业务
    self.modelclass = [FoucsModel class];
    self.keyStr = @"data";
    _reponseType = TYPE_ARRAY;
    [self startPostRequest];
}
//取消关注
- (void)friendsUpdate:(NSString *)friednsId{
    _hostUrl = [NSString stringWithFormat:@"%@friends/update",HOST];
    _paramDict[@"usersId"] = [NSString stringWithFormat:@"%@",KUSER.usersId];
    _paramDict[@"friendsId"] = friednsId;
    _paramDict[@"token"] = [UserDefaultStandard objectForKey:@"token"];
    _paramDict[@"sign"] = @"";
    //启动业务
    self.keyStr = @"data";
    self.decodeData = ^id(id data) {
        return data;
    };
    [self startPostRequest];
}
//添加关注
- (void)friendsAdd:(NSString *)acceptUsersId{
    _hostUrl = [NSString stringWithFormat:@"%@friends/friendsAdd",HOST];
    _paramDict[@"usersId"] = [NSString stringWithFormat:@"%@",KUSER.usersId];
    _paramDict[@"acceptUsersId"] = acceptUsersId;
    _paramDict[@"token"] = [UserDefaultStandard objectForKey:@"token"];
    _paramDict[@"sign"] = @"";
    //启动业务
    self.keyStr = @"data";
    self.decodeData = ^id(id data) {
        return data;
    };
    [self startPostRequest];
}
//完成NPC问题领取车票
- (void)usersAddTicket{
    _hostUrl = [NSString stringWithFormat:@"%@users/addTicket",HOST];
    _paramDict[@"usersId"] = [NSString stringWithFormat:@"%@",KUSER.usersId];
    _paramDict[@"token"] = [UserDefaultStandard objectForKey:@"token"];
    _paramDict[@"sign"] = @"";
    //启动业务
    self.keyStr = @"data";
    self.decodeData = ^id(id data) {
        return data;
    };
    [self startPostRequest];
}

//敏感词
- (void)findSensitiveWords{
    _hostUrl = [NSString stringWithFormat:@"%@sensitiveWords/find",HOST];
//    _paramDict[@"usersId"] = [NSString stringWithFormat:@"%@",KUSER.usersId];
//    _paramDict[@"friednsId"] = friednsId;
//    _paramDict[@"token"] = [UserDefaultStandard objectForKey:@"token"];
//    _paramDict[@"sign"] = @"";
    //启动业务
    self.keyStr = @"data";
    self.decodeData = ^id(id data) {
        return [data objectForKey:@"data"];
    };
    [self startPostRequest];
}


//添加答题记录
- (void)saveUsersStoryRecord:(NSString *)storyId storyVersion:(NSString *)storyVersion isTrue:(NSString *)isTrue createUsersId:(NSString *)createUsersId createType:(NSString *)createType {
    
    _hostUrl = [NSString stringWithFormat:@"%@usersStoryRecord/save",HOST];
    _paramDict[@"usersId"] = [NSString stringWithFormat:@"%@",KUSER.usersId];
    _paramDict[@"token"] = [UserDefaultStandard objectForKey:@"token"];
    _paramDict[@"storyId"] = storyId;
    _paramDict[@"isTrue"] = isTrue;
    _paramDict[@"createUsersId"] = createUsersId;
    _paramDict[@"storyVersion"] = storyVersion;
//    0平台1用户
    _paramDict[@"createType"] = createType;

    
    _paramDict[@"sign"] = @"";
    //启动业务
    self.keyStr = @"data";
    self.decodeData = ^id(id data) {
        return data;
    };
    [self startPostRequest];
}

//修改用昵称
- (void)updUsersInfoNickName:(NSString *)nickName{
    _hostUrl = [NSString stringWithFormat:@"%@users/updUsersInfo",HOST];
    _paramDict[@"nickName"] = [self replacernk:nickName];
    _paramDict[@"token"] = [UserDefaultStandard objectForKey:@"token"];
    _paramDict[@"usersId"] = [NSString stringWithFormat:@"%@",KUSER.usersId];
    _paramDict[@"sign"] = @"";
    //启动业务
    self.decodeData = ^id(id data) {
        return data;
    };
    //    _reponseType = TYPE_OTHER;
    [self startPostRequest];
}

//车票兑换记录
- (void)findExchangeRecords:(NSString *)pageNo{
    _hostUrl = [NSString stringWithFormat:@"%@exchangeRecords/find",HOST];
    _paramDict[@"usersId"] = [NSString stringWithFormat:@"%@",KUSER.usersId];
    _paramDict[@"pageNo"] = pageNo;
    _paramDict[@"pageSize"] = @"10";
    _paramDict[@"token"] = [UserDefaultStandard objectForKey:@"token"];
    _paramDict[@"sign"] = @"";

    //启动业务
    self.modelclass = [RecordModel class];
    self.keyStr = @"data";
    _reponseType = TYPE_ARRAY;
    [self startPostRequest];
}

//查询协议
- (void)findOthers:(NSString *)othersId{
    _hostUrl = [NSString stringWithFormat:@"%@others/find",HOST];
    _paramDict[@"usersId"] = [NSString stringWithFormat:@"%@",KUSER.usersId];
//    1:使用条款|2:隐私条款
    _paramDict[@"othersId"] = othersId;

    _paramDict[@"token"] = [UserDefaultStandard objectForKey:@"token"];
    _paramDict[@"sign"] = @"";
    //启动业务
    self.decodeData = ^id(id data) {
        return [data objectForKey:@"data"];
    };
    [self startPostRequest];
}

//查询天使
- (void)angelFind{
    _hostUrl = [NSString stringWithFormat:@"%@angel/find",HOST];
    _paramDict[@"usersId"] = [NSString stringWithFormat:@"%@",KUSER.usersId];
    _paramDict[@"token"] = [UserDefaultStandard objectForKey:@"token"];
    //0女1男
    _paramDict[@"sex"] = [NSString stringWithFormat:@"%@",KUSER.sex];
    _paramDict[@"sign"] = @"";
    //启动业务
    self.modelclass = [AngelModel class];
    self.keyStr = @"data";
    _reponseType = TYPE_ARRAY;
    [self startPostRequest];
}
//修改用户天使
- (void)updUsersAngleInfo:(NSString *)portraitIm portraitImMin:(NSString *)portraitImMin{
    _hostUrl = [NSString stringWithFormat:@"%@users/updUsersInfo",HOST];
    _paramDict[@"portraitIm"] = portraitIm;
    _paramDict[@"portraitImMin"] = portraitImMin;

    _paramDict[@"token"] = [UserDefaultStandard objectForKey:@"token"];
    _paramDict[@"usersId"] = [NSString stringWithFormat:@"%@",KUSER.usersId];
    _paramDict[@"sign"] = @"";
    //启动业务
    self.decodeData = ^id(id data) {
        return data;
    };
    //    _reponseType = TYPE_OTHER;
    [self startPostRequest];
}
//查询地图
- (void)mapFind{
    _hostUrl = [NSString stringWithFormat:@"%@map/find",HOST];
    _paramDict[@"usersId"] = [NSString stringWithFormat:@"%@",KUSER.usersId];
    _paramDict[@"token"] = [UserDefaultStandard objectForKey:@"token"];
    _paramDict[@"sign"] = @"";
    //启动业务
    self.modelclass = [MapModel class];
    self.keyStr = @"data";
    _reponseType = TYPE_ARRAY;
    [self startPostRequest];
}
//修改用户地图
- (void)updUsersMapInfo:(NSString *)mapId {
    _hostUrl = [NSString stringWithFormat:@"%@users/updUsersInfo",HOST];
    _paramDict[@"mapId"] = mapId;
    _paramDict[@"token"] = [UserDefaultStandard objectForKey:@"token"];
    _paramDict[@"usersId"] = [NSString stringWithFormat:@"%@",KUSER.usersId];
    _paramDict[@"sign"] = @"";
    //启动业务
    self.decodeData = ^id(id data) {
        return data;
    };
    //    _reponseType = TYPE_OTHER;
    [self startPostRequest];
}

//添加地图印记
- (void)imprintInsert:(NSString *)title content:(NSString *)content tab:(NSString *)tab lat:(NSString *)lat lng:(NSString *)lng address:(NSString *)address imgArr:(NSArray *)imgArr{
    _hostUrl = [NSString stringWithFormat:@"%@imprint/insert",HOST];
    _paramDict[@"title"] = title;
    _paramDict[@"tab"] = tab;
    _paramDict[@"content"] = [self replacernk:content];
    _paramDict[@"lng"] = lng;
    _paramDict[@"lat"] = lat;
    _paramDict[@"address"] = address;
    for (int i = 0; i < imgArr.count; i ++) {
        UIImage *originImage = [imgArr objectAtIndex:i];
        NSData *data =   [UIImage resetSizeOfImageData:originImage maxSize:50];
        NSString *encodedImageStr = [data base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];
        encodedImageStr = [encodedImageStr stringByReplacingOccurrencesOfString:@"\r" withString:@""];
        encodedImageStr = [encodedImageStr stringByReplacingOccurrencesOfString:@"\n" withString:@""];
        encodedImageStr = [encodedImageStr stringByReplacingOccurrencesOfString:@" " withString:@""];
        //    _paramDict[@"base64Str"] = encodedImageStr;
        NSString *keyName = [NSString stringWithFormat:@"image%d",i+1];
        _paramDict[keyName] = encodedImageStr;
    }

    _paramDict[@"token"] = [UserDefaultStandard objectForKey:@"token"];
    _paramDict[@"usersId"] = [NSString stringWithFormat:@"%@",KUSER.usersId];
    _paramDict[@"sign"] = @"";
    //启动业务
    self.decodeData = ^id(id data) {
        return data;
    };
    //    _reponseType = TYPE_OTHER;
    [self startPostRequest];
}

//印记点赞
- (void)addOrRemoveIP:(NSString *)imprintId type:(NSString *)type{
    _hostUrl = [NSString stringWithFormat:@"%@imprintPraise/addOrRemoveIP",HOST];
    _paramDict[@"usersId"] = [NSString stringWithFormat:@"%@",KUSER.usersId];
//    1删除点赞 0添加点赞
    _paramDict[@"type"] = type;
    _paramDict[@"imprintId"] = imprintId;

    _paramDict[@"token"] = [UserDefaultStandard objectForKey:@"token"];
    _paramDict[@"sign"] = @"";
    //启动业务
    self.keyStr = @"data";
    self.decodeData = ^id(id data) {
        return data;
    };
    [self startPostRequest];
}
//查询随机场景
- (void)sceneFind {
    _hostUrl = [NSString stringWithFormat:@"%@scene/find",HOST];
    _paramDict[@"usersId"] = [NSString stringWithFormat:@"%@",KUSER.usersId];
    _paramDict[@"token"] = [UserDefaultStandard objectForKey:@"token"];
    _paramDict[@"sign"] = @"";
    //启动业务
    self.keyStr = @"data";
    self.decodeData = ^id(id data) {
        return data;
    };
    [self startPostRequest];
}

//根据印记id查询印记详情
- (void)imprintFind:(NSString *)imprintId{
    _hostUrl = [NSString stringWithFormat:@"%@imprint/find",HOST];
    _paramDict[@"usersId"] = [NSString stringWithFormat:@"%@",KUSER.usersId];
    _paramDict[@"token"] = [UserDefaultStandard objectForKey:@"token"];
    _paramDict[@"imprintId"] = imprintId;
    _paramDict[@"sign"] = @"";
    //启动业务
    self.keyStr = @"data";
    self.modelclass = [YinjiModel class];

//    self.decodeData = ^id(id data) {
//        return [data objectForKey:@"data"];
//    };
    [self startPostRequest];
}

//查询个人信息页故事和印记
- (void)storyFindStoryAndIPByUsersId:(NSString *)usersId{
    _hostUrl = [NSString stringWithFormat:@"%@story/findStoryAndIPByUsersId",HOST];
    _paramDict[@"usersId"] = usersId;
//    _paramDict[@"loginUsersId"] = [NSString stringWithFormat:@"%@",KUSER.usersId];
    _paramDict[@"token"] = [UserDefaultStandard objectForKey:@"token"];
    _paramDict[@"sign"] = @"";
    //启动业务
    self.modelclass = [UserStoryYinJiModel class];
    self.keyStr = @"data";
    _reponseType = TYPE_ARRAY;
    [self startPostRequest];
}


//添加反馈
- (void)feedbackInsert:(NSString *)content {
    _hostUrl = [NSString stringWithFormat:@"%@feedback/insert",HOST];
    _paramDict[@"usersId"] = [NSString stringWithFormat:@"%@",KUSER.usersId];
    _paramDict[@"content"] = [self replacernk:content];
    _paramDict[@"token"] = [UserDefaultStandard objectForKey:@"token"];
    _paramDict[@"sign"] = @"";
    //启动业务
    self.keyStr = @"data";
    self.decodeData = ^id(id data) {
        return data;
    };
    [self startPostRequest];
}
//印记举报
- (void)imprintReportAdd:(NSString *)content imprintId:(NSString *)imprintId{
    _hostUrl = [NSString stringWithFormat:@"%@imprintReport/add",HOST];
    _paramDict[@"usersId"] = [NSString stringWithFormat:@"%@",KUSER.usersId];
    _paramDict[@"content"] = [self replacernk:content];
    _paramDict[@"token"] = [UserDefaultStandard objectForKey:@"token"];
    _paramDict[@"imprintId"] = imprintId;
    _paramDict[@"sign"] = @"";
    //启动业务
    self.keyStr = @"data";
    self.decodeData = ^id(id data) {
        return data;
    };
    [self startPostRequest];
}

//查询启动图
- (void)startPageFind{
    _hostUrl = [NSString stringWithFormat:@"%@startPage/find",HOST];
    _paramDict[@"usersId"] = @"";
//    _paramDict[@"token"] = [UserDefaultStandard objectForKey:@"token"];
    
    _paramDict[@"sign"] = @"";
    //启动业务
    self.keyStr = @"data";
    self.decodeData = ^id(id data) {
        return data;
    };
    [self startPostRequest];
}
//获取预支付id或订单号
- (void)ordersFindPrepayId:(NSString *)num{
    _hostUrl = [NSString stringWithFormat:@"%@orders/findPrepayId",HOST];
    _paramDict[@"usersId"] = [NSString stringWithFormat:@"%@",KUSER.usersId];
    if ([num isEqualToString:@"1"]) {
        _paramDict[@"buyMoney"] = @"12";
        _paramDict[@"buyNum"] = @"72";
    }else if ([num isEqualToString:@"2"]) {
        _paramDict[@"buyMoney"] = @"18";
        _paramDict[@"buyNum"] = @"108";
    }else if ([num isEqualToString:@"3"]) {
        _paramDict[@"buyMoney"] = @"30";
        _paramDict[@"buyNum"] = @"204";
    }else if ([num isEqualToString:@"4"]) {
        _paramDict[@"buyMoney"] = @"98";
        _paramDict[@"buyNum"] = @"708";
    }
    _paramDict[@"payType"] = @"2";
    _paramDict[@"sign"] = @"";
    //启动业务
    self.keyStr = @"data";
    self.decodeData = ^id(id data) {
        return data;
    };
    [self startPostRequest];
}
//内购成功
- (void)ordersPaySuccess:(NSString *)ordersId{
    _hostUrl = [NSString stringWithFormat:@"%@orders/paySuccess",HOST];
    _paramDict[@"usersId"] = [NSString stringWithFormat:@"%@",KUSER.usersId];
    _paramDict[@"ordersId"] = ordersId;
    _paramDict[@"sign"] = @"";
    //启动业务
    self.keyStr = @"data";
    self.decodeData = ^id(id data) {
        return data;
    };
    [self startPostRequest];
}
//添加黑名单
- (void)blacklistAdd:(NSString *)acceptUsersId{
    _hostUrl = [NSString stringWithFormat:@"%@blacklist/add",HOST];
    _paramDict[@"usersId"] = [NSString stringWithFormat:@"%@",KUSER.usersId];
    _paramDict[@"acceptUsersId"] = acceptUsersId;
    _paramDict[@"sign"] = @"";
    //启动业务
    self.keyStr = @"data";
    self.decodeData = ^id(id data) {
        return data;
    };
    [self startPostRequest];
}

- (NSString *)replacernk:(NSString *)encodedImageStr {
    encodedImageStr = [encodedImageStr stringByReplacingOccurrencesOfString:@"\r" withString:@""];
    encodedImageStr = [encodedImageStr stringByReplacingOccurrencesOfString:@"\n" withString:@""];
    encodedImageStr = [encodedImageStr stringByReplacingOccurrencesOfString:@"\t" withString:@""];
    encodedImageStr = [encodedImageStr stringByReplacingOccurrencesOfString:@" " withString:@""];
    return encodedImageStr;
}
@end
